﻿package mortal.game.view.copy.worldBoss.smallBossPanel
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.*;
    import mortal.mvc.core.*;

    public class SmallBossMiniView extends CopyInfoPanelBase
    {
        protected var _bossNameTitle:GTextFiled;
        protected var _hurtList:GTileList;
        protected var _myRank:GTextFiled;
        protected var _myHurt:GTextFiled;
        protected var _bossName2:GTextFiled;
        protected var _dropItemList:GTileList;
        protected var _autoFightBtn:GLoadingButton;
        private var _t:int = 0;
        private static var _instance:SmallBossMiniView;

        public function SmallBossMiniView()
        {
            super(ImagesConst.copyInfoPanelTitleSmallBoss, 286, 400);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            _moveBtn.y = 16;
            _btnUnExpand.y = 16;
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.WorldSmallBossMiniBg, 0, 0, _bodySprite));
            pushUIToDisposeVec(UIFactory.bg(12, 45, 263, 150, _bodySprite));
            pushUIToDisposeVec(UIFactory.bg(14, 47, 262, 24, _bodySprite, ImagesConst.RegionTitleBg));
            this._bossNameTitle = UIFactory.gTextField("", 0, 17, 135, 20, _bodySprite, GlobalStyle.textFormatHuang2.right());
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21423), 18, 48, 50, 20, _bodySprite));
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21424), 70, 48, 50, 20, _bodySprite));
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21433), 205, 48, 50, 20, _bodySprite));
            this._hurtList = UIFactory.tileList(17, 70, 260, 120, _bodySprite);
            this._hurtList.columnWidth = 260;
            this._hurtList.rowHeight = 24;
            this._hurtList.setStyle("cellRenderer", SmallBossHurtCellRender);
            this._myRank = UIFactory.gTextField("", 148, 197, 50, 20, _bodySprite, GlobalStyle.textFormatChen);
            this._myHurt = UIFactory.gTextField("", 200, 197, 80, 20, _bodySprite);
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(21434), 21, 220, 240, 20, _bodySprite, GlobalStyle.textFormatLv));
            this._bossName2 = UIFactory.gTextField("", 0, 270, 120, 20, _bodySprite, GlobalStyle.textFormatHuang2.right());
            this._dropItemList = UIFactory.tileList(70, 295, 150, 100, _bodySprite);
            this._dropItemList.columnWidth = 50;
            this._dropItemList.rowHeight = 50;
            this._dropItemList.setStyle("cellRenderer", SmallBossItemRewardCellRenderer);
            this._autoFightBtn = UIFactory.gLoadingButton(ResFileConst.autoFightBtn, 100, 409, 103, 38, _bodySprite);
            this._autoFightBtn.configEventListener(MouseEvent.CLICK, this.clickHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bossNameTitle.dispose();
            this._bossNameTitle = null;
            this._hurtList.dispose();
            this._hurtList = null;
            this._myRank.dispose();
            this._myRank = null;
            this._myHurt.dispose();
            this._myHurt = null;
            this._bossName2.dispose();
            this._bossName2 = null;
            this._dropItemList.dispose();
            this._dropItemList = null;
            this._autoFightBtn.dispose();
            this._autoFightBtn = null;
            if (this._t)
            {
                clearTimeout(this._t);
                this._t = 0;
            }
            super.disposeImpl();
            return;
        }// end function

        private function clickHandler(event:MouseEvent) : void
        {
            AIManager.cancelAll();
            Dispatcher.dispatchEvent(new DataEvent(EventName.AutoFight_A));
            return;
        }// end function

        public function updateHurtList(param1:SFieldBossHurtList) : void
        {
            var _loc_2:* = param1.bossCode;
            var _loc_3:* = BossConfig.instance.getInfoByCode(param1.bossCode);
            var _loc_4:* = WorldBossConfig.instance.getWorldBossByCode(param1.bossCode);
            var _loc_5:* = param1.topInfos.pop();
            var _loc_6:Array = [];
            if (_loc_4)
            {
                _loc_6 = _loc_4.bossDrop.split("#");
            }
            this._bossNameTitle.text = _loc_3.name;
            this._bossName2.text = _loc_3.name;
            this._hurtList.dataProvider = new DataProvider(param1.topInfos);
            this._myRank.text = _loc_5.rank.toString();
            this._myHurt.text = _loc_5.hurt.toString();
            this._dropItemList.dataProvider = new DataProvider(_loc_6);
            this.addDelayClose();
            return;
        }// end function

        protected function addDelayClose() : void
        {
            if (this._t)
            {
                clearTimeout(this._t);
            }
            this._t = setTimeout(this.hide, 5000);
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskShowHideTrackExceptBtn, true));
            return;
        }// end function

        public static function get instance() : SmallBossMiniView
        {
            if (!_instance)
            {
                _instance = new SmallBossMiniView;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
